package com.xianyun.book.gatewayimpl.elasticsearch.repository;

import com.xianyun.book.gatewayimpl.elasticsearch.dataobject.BookEsDO;
import org.springframework.lang.Nullable;
import java.util.List;

/**
 * @author macos-zyj
 */
public interface BookEsRepository {
    /**
     * create Index
     *
     * @param index elasticsearch index name
     * @author fxbin
     */
    void createBookIndex(String index);

    /**
     * delete Index
     *
     * @param index elasticsearch index name
     * @author fxbin
     */
    void deleteBookIndex(String index);

    /**
     * insert document source
     *
     * @param index elasticsearch index name
     * @param list  data source
     * @author fxbin
     */
    void insertBook(String index, List<BookEsDO> list);

    /**
     * update document source
     *
     * @param index elasticsearch index name
     * @param list  data source
     * @author fxbin
     */
    void updateBook(String index, List<BookEsDO> list);

    /**
     * delete document source
     *
     * @param bookEs delete data source and allow null object
     * @param index  elasticsearch index name
     * @author fxbin
     */
    void deleteBook(String index, @Nullable BookEsDO bookEs);

    /**
     * search all doc records
     *
     * @param index elasticsearch index name
     * @return person list
     * @author fxbin
     */
    List<BookEsDO> searchBookList(String index);

    /**
     * 模糊查询
     * @param field 字段名称
     * @param value 查询名称
     * @return bookList
     */
    List<BookEsDO> queryMatchList(String field, String value);

    /**
     * get recommend
     * @param searchKey
     * @return
     */
    List<String> searchBookSuggest(String searchKey);
}
